<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*"
	import="java.sql.*" import="henu.bean.*" import="henu.others.*" %>
	<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
	<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>在线考试系统</title>
		<link rel="stylesheet" href="../css/bootstrap.min.css">
		<link rel="stylesheet" href="../css/bootstrap-datetimepicker.min.css">
		<script src="../js/jquery-2.1.4.js"></script>
		<script src="../js/bootstrap-datetimepicker.js"></script>
		<script src="../js/bootstrap-datetimepicker.fr.js"></script>
		<script src="../js/bootstrap.min.js"></script>
		<style>
			body {
				background-image: url(../picture/bg3.jpg);
				background-size: cover;
			}
			.table-footer>.pagination-box {
				display: inline-flex;
				align-items: center;
				justify-content: flex-end;
			}
		</style>
	</head>

	<body>
		<div class="container"> 
			<div class="row clearfix">
				<div class="col-md-12 column">
					<nav class="navbar navbar-default" role="navigation">
						<div class="container-fluid">
							<div class="navbar-header">
								<a class="navbar-brand" href="teacherHome.jsp">在线考试系统</a>
							</div>
							<div> 
								<ul class="nav navbar-nav">
									<li class="dropdown"><a href="#" class="dropdown-toggle"
											data-toggle="dropdown">试题管理<strong class="caret"></strong></a>
										<ul class="dropdown-menu">
											<li><a href="addQuestion.jsp">添加试题</a></li>
											<li><a href="../ManagementQuestion?method=findchoiceQuestion">选择题维护</a>
											</li>
											<li><a href="../ManagementQuestion?method=findmultichoiceQuestion">多选题维护</a>
											</li>
											<li><a href="../ManagementQuestion?method=findjudgeQuestion">判断题维护</a>
											</li>
										</ul>
									</li>
									<li class="dropdown active"><a href="#" class="dropdown-toggle"
											data-toggle="dropdown">发布试卷<strong class="caret"></strong></a>
										<ul class="dropdown-menu">
											<li><a href="makePaper.jsp">随机组卷</a>
											</li>
											<li><a href="makePaperV3.jsp">手动组卷</a>
											</li>
										</ul>
									</li>
									<li><a href="../ReleaseHistory?method=findpaperHistory">历史发布</a>
									</li>
									<li><a href="../Statistic?method=findStatistics">统计情况</a></li>
									<li><a href="../ManagementMessage?method=findAcceptMessage">学生留言</a></li>
								</ul>
							</div>
							<ul class="nav navbar-nav navbar-right">
								<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span
											class="glyphicon glyphicon-user"></span>我的<strong
											class="caret"></strong></a>
									<ul class="dropdown-menu">
										<li><a href="../PersonalInfo?method=findTeacherInfo">个人信息</a>
										</li>
										<li><a href="updateTPW.jsp">修改密码</a></li>
										<li><a href="../LoginServlet?usertype=logout">注销</a></li>
									</ul>
								</li>
							</ul>
						</div>
					</nav>
				</div>

				<br>
					<% 
						subject sj = new subject(); List<Subject> records = sj.getSubject(); 
						myClass c = new myClass(); List<Classbean> classes = c.getmyClass();
					%>
					<label>学科：</label> 
					<select id="subjectid"  name="subjectid" class="btn btn-default dropdown-toggle" onchange="loadTablePage()">
						<% if (records==null || records.size()==0) { 
								out.println("<option>还没有学科~</option>");
							} else {
								for (Subject s : records) {
						%>
							<option value=<%=s.getSubjectid()%>>
								<%=s.getSubjectname()%>
							</option>
							<% } } %> 
					</select>
				
					<span>&emsp;</span>
					<label>班级：</label>
					<select id="classid"  name="classid" class="btn btn-default dropdown-toggle">
						<%if (classes == null || classes.size() == 0) {
							out.println("<option>还没有班级~</option>");						
							} else {
								for (Classbean r : classes) {	
						%>
							<option value=<%=r.getClassid() %>>
								<%=r.getClassname() %>
							</option>
							<% } } %>
					</select>
					
					
					<span>&emsp;</span>
					<label>开始时间：</label>
					<input id="startTime" name="starttime" type="text" readonly class="form_datetime" style="width: 165px;" /> 

					
					<span>&emsp;</span>
					<label>结束时间：</label>  
					<input id="endTime" name="endtime" type="text" readonly class="form_datetime" style="width: 165px;" />  
					
					<span>&emsp;</span>
					<label>试卷名：</label>
					<input id="paperName" type="text" name="papername"  style="width: 165px;" />  
					<input type="submit" class="btn btn-sm btn-success" value="确定" onclick="makePaper()"/> 
				<br> 
				<br>
				<!-- 选择题 --> 
				<br>
				<div class="jumbotron" id="oneTableContentDiv">
					<label>选择题：</label>
					<br/>
					<br/>
					<label>每页展示：</label>
					<select id="onePageSize" class="btn btn-default dropdown-toggle" onchange="updateTablePageSize(document.getElementById('onePageSize').value,'onePageSize')">
					    <option value="3">3</option>
					    <option value="5">5</option>
					    <option value="10">10</option>
					</select>
					<table class="table table-hover table-bordered" id="oneTable">
						<thead>
							<tr>
								<th>编号</th> 
								<th>问题</th>
								<th>选项A</th>
								<th>选项B</th>
								<th>选项C</th>
								<th>选项D</th>
								<th>答案</th>
								<th>选中</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<!-- 分页条 -->
					<div class="table-footer row">
						<div class="pagination-box">
							<span class="oneDataInfo"></span>
							<ul class="pagination">
								<li><span class="oneStartPage" aria-label="Start" aria-hidden="true">&laquo;</span></li>
								<li><span class="onePrevPage" aria-label="Previous" aria-hidden="true">&lt;</span></li>
								<li class="active"><span class="oneNowPage">1</span></li>
								<li><span class="oneNextPage" aria-label="Next" aria-hidden="true">&gt;</span></li>
								<li><span class="oneEndPage" aria-label="End" aria-hidden="true">&raquo;</span></li>
							</ul>
						</div>
					</div>
				</div>

				
				
				<!-- 多选题 --> 
				<br>
				<div class="jumbotron" id="twoTableContentDiv">
					<label>多选题：</label>
					<br/>
					<br/>
					<label>每页展示：</label>
					<select id="twoPageSize" class="btn btn-default dropdown-toggle" onchange="updateTablePageSize(document.getElementById('twoPageSize').value,'twoPageSize')">
					    <option value="3">3</option>
					    <option value="5">5</option>
					    <option value="10">10</option>
					</select>
					<table class="table table-hover table-bordered" id="twoTable">
						<thead>
							<tr>
								<th>编号</th> 
								<th>问题</th>
								<th>选项A</th>
								<th>选项B</th>
								<th>选项C</th>
								<th>选项D</th>
								<th>答案</th>
								<th>选中</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<!-- 分页条 -->
					<div class="table-footer row">
						<div class="pagination-box">
							<span class="twoDataInfo"></span>
							<ul class="pagination">
								<li><span class="twoStartPage" aria-label="Start" aria-hidden="true">&laquo;</span></li>
								<li><span class="twoPrevPage" aria-label="Previous" aria-hidden="true">&lt;</span></li>
								<li class="active"><span class="oneNowPage">1</span></li>
								<li><span class="twoNextPage" aria-label="Next" aria-hidden="true">&gt;</span></li>
								<li><span class="twoeEndPage" aria-label="End" aria-hidden="true">&raquo;</span></li>
							</ul>
						</div>
					</div>
				</div>
							
				<!-- 判断题 -->
				<br> 
				<div class="jumbotron" id="threeTableContentDiv">
					<label>判断题：</label>
					<br/>
					<br/>
					<label>每页展示：</label>
					<select id="threePageSize" class="btn btn-default dropdown-toggle" onchange="updateTablePageSize(document.getElementById('threePageSize').value,'threePageSize')">
					    <option value="3">3</option>
					    <option value="5">5</option>
					    <option value="10">10</option>
					</select>
					<table class="table table-hover table-bordered" id="threeTable">
						<thead>
							<tr>
								<th>编号</th> 
								<th>问题</th>
								<th>答案</th>
								<th>选中</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<!-- 分页条 -->
					<div class="table-footer row">
						<div class="pagination-box">
							<span class="threeDataInfo"></span>
							<ul class="pagination">
								<li><span class="threeStartPage" aria-label="Start" aria-hidden="true">&laquo;</span></li>
								<li><span class="threePrevPage" aria-label="Previous" aria-hidden="true">&lt;</span></li>
								<li class="active"><span class="threeNowPage">1</span></li>
								<li><span class="threeNextPage" aria-label="Next" aria-hidden="true">&gt;</span></li>
								<li><span class="threeEndPage" aria-label="End" aria-hidden="true">&raquo;</span></li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript"> 
			// 在页面加载完成后触发
			window.onload = function () {
				showTableDiv = false;
				initVar();
				loadTablePage();
			    // var jumbotron = document.getElementById("oneTableContentDiv");
		    	// jumbotron.style.display = "none";
			    // jumbotron = document.getElementById("twoTableContentDiv");
		    	// jumbotron.style.display = "none";
			    // jumbotron = document.getElementById("threeTableContentDiv");
		    	// jumbotron.style.display = "none";
			};

			// 创建一个空数组来存储选中的题号
			var oneSelectedQuestions = [];
			var twoSelectedQuestions = [];
			var threeSelectedQuestions = [];

			//  每页展示条数
			var onePageSize = 3;
			var twoPageSize = 3;
			var threePageSize = 3;

			// totalItems: 数据总条数
			var oneTotalItems = 0;
			var twoTotalItems = 0;
			var threeTotalItems = 0;
 
			// totalPages: 页面总数，向上取整
			var oneTotalPages = 1;
			var twoTotalPages = 1;
			var threeTotalPages = 1;

			// curPage: 当前页数 
			var oneCurPage = 1;
			var twoCurPage = 1;
			var threeCurPage = 1;

			// 首次加载时，绑定点击事件
			var oneIsFirst = true;
			var twoIsFirst = true;
			var threeIsFirst = true;

			// 是否显示table
			var showTableDiv = false;

			$(".form_datetime").datetimepicker({ format: 'yyyy-mm-dd hh:ii' });
			// 绑定分页事件
			$(document).ready(function() {
				// 选择
				// 回到第一页
				$(".oneStartPage").click(function() {
					if (oneCurPage > 1) {
						// 如果当前不是第一页
						oneCurPage = 1;
						// 更新数据
						getChoiceTableContent(oneCurPage);
					} else {
						alert("当前已经在第一页");
					}
				});

				// 上一页
				$(".onePrevPage").click(function() {
				    if (oneCurPage > 1) {
						// 如果当前不是第一页
						oneCurPage = oneCurPage - 1;
						// 更新数据
						getChoiceTableContent(oneCurPage);
					} else {
						alert("当前已经在第一页");
					}
				});

				// 下一页
				$(".oneNextPage").click(function() {
					if (oneCurPage < oneTotalPages) {
						// 如果当前不是最后一页
						oneCurPage = oneCurPage + 1;
						// 更新数据
						getChoiceTableContent(oneCurPage);
					} else {
						alert("当前已经在最后一页");
					}
				});

				// 最后一页
				$(".oneEndPage").click(function() {
					if (oneCurPage < oneTotalPages) {
						// 如果当前不是最后一页
						oneCurPage = oneTotalPages;
						// 更新数据
						getChoiceTableContent(oneCurPage);
					} else {
						alert("当前已经在最后一页");
					}
				});

				
				// 多选
				$(".twoStartPage").click(function() {
					if (twoCurPage > 1) {
						// 如果当前不是第一页
						twoCurPage = 1;
						// 更新数据
						getMultiChoiceTableContent(twoCurPage);
					} else {
						alert("当前已经在第一页");
					}
				});
				$(".twoPrevPage").click(function() {
				    if (twoCurPage > 1) {
						// 如果当前不是第一页
						twoCurPage = twoCurPage - 1;
						// 更新数据
						getMultiChoiceTableContent(twoCurPage);
					} else {
						alert("当前已经在第一页");
					}
				});
				$(".twoNextPage").click(function() {
					if (twoCurPage < twoTotalPages) {
						// 如果当前不是最后一页
						twoCurPage = twoCurPage + 1;
						// 更新数据
						getMultiChoiceTableContent(twoCurPage);
					} else {
						alert("当前已经在最后一页");
					}
				});
				$(".twoEndPage").click(function() {
					if (twoCurPage < twoTotalPages) {
						// 如果当前不是最后一页
						twoCurPage = twoTotalPages;
						// 更新数据
						getMultiChoiceTableContent(twoCurPage);
					} else {
						alert("当前已经在最后一页");
					}
				});


				// 判断
				$(".threeStartPage").click(function() {
					if (threeCurPage > 1) {
						// 如果当前不是第一页
						threeCurPage = 1;
						// 更新数据
						getJudgeTableContent(threeCurPage);
					} else {
						alert("当前已经在第一页");
					}
				}); 
				$(".threePrevPage").click(function() {
				    if (threeCurPage > 1) {
						// 如果当前不是第一页
						threeCurPage = threeCurPage - 1;
						// 更新数据
						getJudgeTableContent(threeCurPage);
					} else {
						alert("当前已经在第一页");
					}
				});
				$(".threeNextPage").click(function() {
					if (threeCurPage < threeTotalPages) {
						// 如果当前不是最后一页
						threeCurPage = threeCurPage + 1;
						// 更新数据
						getJudgeTableContent(threeCurPage);
					} else {
						alert("当前已经在最后一页");
					}
				});
				$(".threeEndPage").click(function() {
					if (threeCurPage < threeTotalPages) {
						// 如果当前不是最后一页
						threeCurPage = threeTotalPages;
						// 更新数据
						getJudgeTableContent(threeCurPage);
					} else { 
						alert("当前已经在最后一页");
					}
				});
			});

			// 获取选择题中该科目的题目
			function getChoiceTableContent(cur){
				console.log(123);
				var subjectid = $("#subjectid").val(); // 获取选中的subjectid
				// 发送 AJAX 请求
				$.ajax({
					type: "POST",
					url: "../MakePaper?method=getChoiceQuestionPages",
					data: {
						subjectid: subjectid,
						pageSize: onePageSize,
						curPage: cur
					}, // 发送选中的学科ID 
					dataType: "json", // 预期服务器返回的数据类型
					success: function (response) {
						var str = "";
						var itemCount = 0; // 数据条目数量
						console.log(123);
						console.log(response);
						$.each(response['data'], function (index, item) {
							str += "<tr class='warning'>"; // 每个项目应该包裹在 <tr> 标签中
							str += "<td>" + item.id + "</td>";
							str += "<td>" + item.question + "</td>";
							str += "<td>" + item.choiceA + "</td>";
							str += "<td>" + item.choiceB + "</td>";
							str += "<td>" + item.choiceC + "</td>";
							str += "<td>" + item.choiceD + "</td>";
							str += "<td>" + item.answer + "</td>";
							// value 为题目id
							str += "<td><input type='checkbox' name='selectedQuestions' value='" + item.id + "' class='question-checkbox'></td>";
							str += "</tr>"; // 关闭 <tr> 标签
							itemCount++; // 计算数据条目数量
						});
						oneTotalPages = response['info']['totalPages'];
						oneTotalItems = response['info']['totalItems'];
						// 更新页脚信息
						var dataInfo = "共" + oneTotalItems + "条 " + oneTotalPages + "页 "
					    $('.oneDataInfo').text(dataInfo);
						// 更新页码信息
					    $('.oneNowPage').text(cur);
 
						$('#oneTable tbody').html(str);
						if (oneIsFirst){ 
							// 绑定点击事件
							$('#oneTable tbody').on('click', 'tr', oneHandleCheckboxToggle);	
							oneIsFirst = false; 
						}
						// 根据选中题号更新复选框选中状态
						updateCheckboxSelection("onePageSize");
					},
					error: function (xhr, status, error) {
						// 请求失败时的处理函数
						console.error("Error: " + error);
					}
				}); 
			}    
   
			// 获取多选题中该科目的题目 
			function getMultiChoiceTableContent(cur){
				var subjectid = $("#subjectid").val(); // 获取选中的subjectid
				// 发送 AJAX 请求
				$.ajax({
					type: "POST",
					url: "../MakePaper?method=getMultiChoiceQuestionPages",
					data: {
						subjectid: subjectid,
						pageSize: twoPageSize,
						curPage: cur
					}, // 发送选中的学科ID 
					dataType: "json", // 预期服务器返回的数据类型
					success: function (response) {
						var str = "";
						var itemCount = 0; // 数据条目数量
						console.log(response);
						$.each(response['data'], function (index, item) {
							str += "<tr class='warning'>"; // 每个项目应该包裹在 <tr> 标签中
							str += "<td>" + item.id + "</td>";
							str += "<td>" + item.question + "</td>";
							str += "<td>" + item.choiceA + "</td>";
							str += "<td>" + item.choiceB + "</td>";
							str += "<td>" + item.choiceC + "</td>";
							str += "<td>" + item.choiceD + "</td>";
							str += "<td>" + item.answer + "</td>";
							// value 为题目id
							str += "<td><input type='checkbox' name='selectedQuestions' value='" + item.id + "' class='question-checkbox'></td>";
							str += "</tr>"; // 关闭 <tr> 标签
							itemCount++; // 计算数据条目数量
						});
						twoTotalPages = response['info']['totalPages'];
						twoTotalItems = response['info']['totalItems'];
						// 更新页脚信息
						var dataInfo = "共" + twoTotalItems + "条 " + twoTotalPages + "页 "
					    $('.twoDataInfo').text(dataInfo);
						// 更新页码信息
					    $('.twoNowPage').text(cur);

						$('#twoTable tbody').html(str);
						if (twoIsFirst){
							// 绑定点击事件
							$('#twoTable tbody').on('click', 'tr', twoHandleCheckboxToggle);	
							twoIsFirst = false; 
						}
						// 根据选中题号更新复选框选中状态
						updateCheckboxSelection("twoPageSize");
					},
					error: function (xhr, status, error) {
						// 请求失败时的处理函数
						console.error("Error: " + error);
					}
				});
			}


			// 获取判断中该科目的题目
			function getJudgeTableContent(cur){
				var subjectid = $("#subjectid").val(); // 获取选中的subjectid
				// 发送 AJAX 请求
				$.ajax({
					type: "POST",
					url: "../MakePaper?method=getJudgeQuestionPages",
					data: {
						subjectid: subjectid,
						pageSize: threePageSize,
						curPage: cur
					}, // 发送选中的学科ID 
					dataType: "json", // 预期服务器返回的数据类型
					success: function (response) {
						var str = "";
						var itemCount = 0; // 数据条目数量
						console.log(response);
						$.each(response['data'], function (index, item) {
							str += "<tr class='warning'>"; // 每个项目应该包裹在 <tr> 标签中
							str += "<td>" + item.id + "</td>";
							str += "<td>" + item.question + "</td>";
							str += "<td>" + (item.answer === 1 ? "正确" : "错误") + "</td>";
							// value 为题目id
							str += "<td><input type='checkbox' name='selectedQuestions' value='" + item.id + "' class='question-checkbox'></td>";
							str += "</tr>"; // 关闭 <tr> 标签
							itemCount++; // 计算数据条目数量
						});
						threeTotalPages = response['info']['totalPages'];
						threeTotalItems = response['info']['totalItems'];
						// 更新页脚信息
						var dataInfo = "共" + threeTotalItems + "条 " + threeTotalPages + "页 "
					    $('.threeDataInfo').text(dataInfo);
						// 更新页码信息
					    $('.threeNowPage').text(cur);

						$('#threeTable tbody').html(str);
						if (threeIsFirst){
							// 绑定点击事件
							$('#threeTable tbody').on('click', 'tr', threeHandleCheckboxToggle);	
							threeIsFirst = false; 
						}
						// 根据选中题号更新复选框选中状态
						updateCheckboxSelection("threePageSize");
					},
					error: function (xhr, status, error) {
						// 请求失败时的处理函数
						console.error("Error: " + error);
					}
				});
			}

			// 复选框触发事件
			function oneHandleCheckboxToggle(e) {
				// 如果点击的是复选框本身，则不执行下面的代码，以避免重复触发
				if (!$(e.target).is('.question-checkbox')) {
					// 切换复选框的选中状态
					var checkbox = $(this).find('.question-checkbox');
					checkbox.prop('checked', !checkbox.prop('checked'));
					// 获取选中的题号
					var selectedQuestionId = checkbox.val();
					// 判断题号是否已存在于数组中
					var index = oneSelectedQuestions.indexOf(selectedQuestionId);
					if (index === -1) {
						// 题号不存在于数组中，将其添加到数组
						oneSelectedQuestions.push(selectedQuestionId);
					} else {
						// 题号已存在于数组中，将其从数组中移除
						oneSelectedQuestions.splice(index, 1);
					}
				}
			}
			function twoHandleCheckboxToggle(e) {
				// 如果点击的是复选框本身，则不执行下面的代码，以避免重复触发
				if (!$(e.target).is('.question-checkbox')) {
					// 切换复选框的选中状态
					var checkbox = $(this).find('.question-checkbox');
					checkbox.prop('checked', !checkbox.prop('checked'));
					// 获取选中的题号
					var selectedQuestionId = checkbox.val();
					// 判断题号是否已存在于数组中
					var index = twoSelectedQuestions.indexOf(selectedQuestionId);
					if (index === -1) {
						// 题号不存在于数组中，将其添加到数组
						twoSelectedQuestions.push(selectedQuestionId);
					} else {
						// 题号已存在于数组中，将其从数组中移除
						twoSelectedQuestions.splice(index, 1);
					}
				}
			}
			function threeHandleCheckboxToggle(e) {
				// 如果点击的是复选框本身，则不执行下面的代码，以避免重复触发
				if (!$(e.target).is('.question-checkbox')) {
					// 切换复选框的选中状态
					var checkbox = $(this).find('.question-checkbox');
					checkbox.prop('checked', !checkbox.prop('checked'));
					// 获取选中的题号
					var selectedQuestionId = checkbox.val();
					// 判断题号是否已存在于数组中
					var index = threeSelectedQuestions.indexOf(selectedQuestionId);
					if (index === -1) {
						// 题号不存在于数组中，将其添加到数组
						threeSelectedQuestions.push(selectedQuestionId);
					} else {
						// 题号已存在于数组中，将其从数组中移除
						threeSelectedQuestions.splice(index, 1);
					}
				}
			}

			// 根据选中题号更新复选框选中状态
			function updateCheckboxSelection(variable) {
				// 获取所有复选框元素
				var checkboxes = "";
				if (variable === 'onePageSize') {
					checkboxes = $('#oneTable .question-checkbox');
				} else if (variable === 'twoPageSize') {
					checkboxes = $('#twoTable .question-checkbox');
				} else if (variable === 'threePageSize') {
					checkboxes = $('#threeTable .question-checkbox');
				}
				checkboxes.each(function () {
					var checkbox = $(this);
					var questionId = checkbox.val();
					// 判断题号是否存在于 selectedQuestions 数组中
					var index = -1
					if (variable === 'onePageSize') {
						index = oneSelectedQuestions.indexOf(questionId);
					} else if (variable === 'twoPageSize') {
						index = twoSelectedQuestions.indexOf(questionId);
					} else if (variable === 'threePageSize') {
						index = threeSelectedQuestions.indexOf(questionId);
					}
					if (index !== -1) { 
						// 选中
						checkbox.prop('checked', true);
					}
				});
			}
			// 修改展示条数
			function updateTablePageSize(num, variable){
				if (variable === 'onePageSize') {
					onePageSize = num;
					oneCurPage = 1;
					getChoiceTableContent(1);
				} else if (variable === 'twoPageSize') {
					twoPageSize = num;
					twoCurPage = 1;
					getMultiChoiceTableContent(1);
				} else if (variable === 'threePageSize') {
					threePageSize = num;
					threeCurPage = 1;
					getJudgeTableContent(1);
				}
			}

			// 初始化table相关参数，并加载table内容
			function loadTablePage(){
				// 显示信息
			    var jumbotron = document.getElementById("oneTableContentDiv");
		    	jumbotron.style.display = "block";
			    jumbotron = document.getElementById("twoTableContentDiv");
		    	jumbotron.style.display = "block";
			    jumbotron = document.getElementById("threeTableContentDiv");
		    	jumbotron.style.display = "block";
				initVar();
				getChoiceTableContent(1);
				getMultiChoiceTableContent(1);
				getJudgeTableContent(1);
			}

			// 制作卷子
			function makePaper(){
				var subjectId = $("#subjectid").val(); // 获取选中的subjectid
				var classId = $("#classid").val(); // 获取选中的班级
				var startTime = $("#startTime").val(); // 开始时间
				var endTime = $("#endTime").val(); // 结束时间
				var paperName = $("#paperName").val(); // 试卷名称
				var pattern = /^[A-Za-z0-9_\u4e00-\u9fa5]+$/; // 正则表达式，匹配数字、字母、下划线和汉字
				if (subjectid === "") {
					alert("学科为空");
					return ;
				}

				if (classid === "") {
					alert("班级为空");
					return ;
				}
 
				if (startTime === "") {
					alert("开始时间为空");
					return ;
				}

				if (endTime === "") {
					alert("结束时间为空");
					return ;
				}

				if (paperName === "") {
					alert("试卷名为空");
					return ;
				}
				if (!pattern.test(paperName)) {
					alert("试卷名只能包含数字、字母、下划线和汉字");
					return ;
				}
				
				var startTimeOb = new Date(startTime); // 转换为日期对象
				var endTimeOb = new Date(endTime); // 转换为日期对象
				var currentTimeOb = new Date(); // 当前时间

				if (startTimeOb <= currentTimeOb) {
					alert("开始时间不能小于当前时间");
					return ;
				}
				
				if (endTimeOb <= startTimeOb) {
					alert("结束时间不能小于开始时间");
					return ; 
				}
				
				if (oneSelectedQuestions.length !== 10) {
					alert("选择题数量应为10道");
					return ;
				}
				if (twoSelectedQuestions.length !== 5) {
					alert("多选题数量应为5道");
					return ;
				}
				if (threeSelectedQuestions.length !== 5) {
					alert("判断数量应为5道");
					return ;
				}
				 
				$.ajax({
					type: "POST",
					url: "../MakePaper?method=makePaperByOwn",
					data: { 
						subjectId: subjectId,
						classId: classId,
						startTime: startTime,
						endTime: endTime,
						paperName: paperName,
						oneSelectedQuestions: JSON.stringify(oneSelectedQuestions),
						twoSelectedQuestions: JSON.stringify(twoSelectedQuestions),
						threeSelectedQuestions: JSON.stringify(threeSelectedQuestions)
					},
					dataType: "json", // 预期服务器返回的数据类型
					success: function (response) {
						alert(response['msg']);
						location.reload();
					},
					error: function (xhr, status, error) {
						alert(response['msg']);
					}
				}); 
			}


			// 初始化页面参数
			function initVar(){
				oneSelectedQuestions = [];
				twoSelectedQuestions = [];
				threeSelectedQuestions = [];
		
				oneTotalItems = 0;
				twoTotalItems = 0;
				threeTotalItems = 0;

				oneTotalPages = 1;
				twoTotalPages = 1;
				threeTotalPages = 1;

				oneCurPage = 1;
				twoCurPage = 1;
				threeCurPage = 1;

				onePageSize = 3;
				twoPageSize = 3;
				threePageSize = 3;
				$('#onePageSize').val('3');
				$('#twoPageSize').val('3');
				$('#threePageSize').val('3');
			}
		</script>
	</body>
</html>